home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 June: Reference Library / Dev.CD Jun 94.toast / Periodicals / develop / develop Issue 18 / develop 18 code / OSA Sample / Sources / ObjModelTokens.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-28  |  5.7 KB  |  226 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ObjModelTokens.h
  3.  
  4.     Contains:    Token classes interface
  5.  
  6.     Developed by:    
  7.         
  8.         Paul G Smith (commstalk hq & Full Moon Software, Inc)
  9.         
  10.         you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  11.         BUT I prefer to be contacted by e-mail
  12.         AppleLink:     SMITH.PG
  13.         Internet:     SMITH.PG@applelink.apple.com
  14.         
  15.         "SimpliFace" Sample code to accompany develop article
  16.         on techniques for embedding scripts in applications.
  17.  
  18.  
  19.     Apple Event Object Model tokens for SimpliFace
  20.  
  21. */
  22.  
  23. #ifndef __AEOMTOKENS__
  24. #define __AEOMTOKENS__
  25.  
  26. #ifndef __SimpliFace__
  27. #include "SimpliFace.h"
  28. #endif
  29.  
  30. #ifndef __SimpliFaceCOMMON__
  31. #include "SimpliFaceCommon.h"
  32. #endif
  33.  
  34. #ifndef __APPLEEVENTS__
  35. #include "AppleEvents.h"
  36. #endif
  37.  
  38. #ifndef __PASCALSTRING__
  39. #include <PascalString.h>
  40. #endif
  41.  
  42. #ifndef __SCRIPTOBJECTS__
  43. #include "ScriptableObjects.h"
  44. #endif
  45.  
  46.  
  47.  
  48. // object model classes
  49.  
  50. class TObjModelToken
  51. {
  52. public:        
  53.                         TObjModelToken(void);                    // constructor
  54.                         TObjModelToken(DescType theTokenClass,
  55.                                         TScriptableObject* theObj);    // initialise
  56.                         TObjModelToken(const TObjModelToken&);    // initialise
  57.     virtual                ~TObjModelToken(void);                    // virtual destructor
  58.     TObjModelToken&    operator=(const TObjModelToken&);
  59.     
  60.     virtual TObjModelToken* MakeClone(void);
  61.     
  62.     // support for object accessors
  63.     
  64.     virtual  TObjModelToken* MakeNewToken(DescType theTokenClass,
  65.                                         TScriptableObject* theObj);
  66.                                         
  67.     virtual  OSErr ResolveElement(DescType desiredClass,
  68.                                         DescType keyForm,
  69.                                         AEDesc *keyData,
  70.                                         TObjModelToken **theResultToken);
  71.                                         
  72.     virtual  OSErr ResolveProperty(DescType desiredClass,
  73.                                         DescType keyForm,
  74.                                         AEDesc *keyData,
  75.                                         TObjModelToken **theResultToken);
  76.                                         
  77.     
  78.     virtual  OSErr DispatchAppleEvent(AppleEvent *theEvent, 
  79.                                             AppleEvent *theReply, 
  80.                                             AEEventClass theEvtClass,
  81.                                             AEEventID theEvtID);
  82.  
  83.              OSErr CallDispatchAppleEvent(AppleEvent *theEvent, 
  84.                                             AppleEvent *theReply, 
  85.                                             AEEventClass theEvtClass,
  86.                                             AEEventID theEvtID);
  87.     
  88.     inline     DescType            GetTokenClass(void)  { return fTokenClass; } ;
  89.     
  90.     inline     TScriptableObject*    GetTokenObj(void)  { return fTheObject; } ;
  91.     
  92. protected:
  93.     DescType             fTokenClass;    // cLine, cWord, cText, cChar, etc
  94.     Boolean                fIsProperty;
  95.     DescType            fPropertyID;
  96.     TScriptableObject*    fTheObject;
  97.     
  98.     // hooks into Apple Event handling, only override for special-purposes;
  99.     // return noErr if Apple Event was handled within the hook function, or 
  100.     // errAEEventNotHandled if it was not handled within the hook function
  101.     
  102.     virtual  OSErr AECountElems        (AppleEvent *theEvent, 
  103.                                             AppleEvent *theReply);
  104.     
  105.     virtual  OSErr AECreateElem        (AppleEvent *theEvent, 
  106.                                             AppleEvent *theReply);
  107.     
  108.     virtual  OSErr AEDeleteElem        (AppleEvent *theEvent, 
  109.                                             AppleEvent *theReply);
  110.     
  111.     virtual  OSErr AECloseObject       (AppleEvent *theEvent, 
  112.                                             AppleEvent *theReply);
  113.     
  114.     virtual  OSErr AEGetObjectData   (AppleEvent *theEvent, 
  115.                                             AppleEvent *theReply);
  116.     
  117.     virtual  OSErr AEOpenObject      (AppleEvent *theEvent, 
  118.                                             AppleEvent *theReply);
  119.     
  120.     virtual  OSErr AESetObjectData   (AppleEvent *theEvent, 
  121.                                             AppleEvent *theReply);
  122.     
  123.     
  124. };
  125.  
  126. // -------------------------------------------------------
  127.  
  128.  
  129. enum {
  130.     typeObjModelToken    = 'OBJX'    // special descriptor type for our tokens
  131. };
  132.  
  133.  
  134. typedef TObjModelToken* objModelTokenPtr;
  135.  
  136.  
  137.  
  138.  
  139.  
  140. // -------------------------------------------------------
  141.  
  142. objModelTokenPtr ObjModelTokenFromDesc(AEDesc *theDesc);
  143.  
  144. OSErr DescFromObjModelToken(const objModelTokenPtr theToken, AEDesc *theDesc);
  145.  
  146.  
  147. OSErr SFinitAEobjects(void);
  148. // set up SF object model handlers
  149.  
  150. OSErr SFendAEobjects(void);
  151. // detach SF object model handlers & shut down
  152.  
  153.  
  154.  
  155.  
  156. // object accessors 
  157.  
  158. pascal OSErr PropertyFromNullAccessor   (DescType desiredClass,
  159.                                                 AEDesc *containerToken,
  160.                                                 DescType containerClass,
  161.                                                 DescType keyForm,
  162.                                                 AEDesc *keyData,
  163.                                                 AEDesc *theToken,
  164.                                                 long theRefCon);
  165.  
  166. OSErr MakeAppToken(TObjModelToken** theApplicationToken);
  167.  
  168. pascal OSErr AppTokenFromNullAccessor   (DescType desiredClass,
  169.                                                 AEDesc *containerToken,
  170.                                                 DescType containerClass,
  171.                                                 DescType keyForm,
  172.                                                 AEDesc *keyData,
  173.                                                 AEDesc *theToken,
  174.                                                 long theRefCon);
  175.  
  176. pascal OSErr WindowTokenFromNullAccessor(DescType desiredClass,
  177.                                                 AEDesc *containerToken,
  178.                                                 DescType containerClass,
  179.                                                 DescType keyForm,
  180.                                                 AEDesc *keyData,
  181.                                                 AEDesc *theToken,
  182.                                                 long theRefCon);
  183.  
  184. pascal OSErr StdObjectFromNullAccessor  (DescType desiredClass,
  185.                                                 AEDesc *containerToken,
  186.                                                 DescType containerClass,
  187.                                                 DescType keyForm,
  188.                                                 AEDesc *keyData,
  189.                                                 AEDesc *theToken,
  190.                                                 long theRefCon);
  191.  
  192.  
  193. static    pascal OSErr StdObjectAccessor (DescType desiredClass,
  194.                                         AEDesc *containerToken,
  195.                                         DescType containerClass,
  196.                                         DescType keyForm,
  197.                                         AEDesc *keyData,
  198.                                         AEDesc *theToken,
  199.                                         long theRefCon);
  200.                                     
  201. static    pascal OSErr StdPropertyAccessor(DescType desiredClass,
  202.                                         AEDesc *containerToken,
  203.                                         DescType containerClass,
  204.                                         DescType keyForm,
  205.                                         AEDesc *keyData,
  206.                                         AEDesc *theToken,
  207.                                         long theRefCon);
  208.  
  209. // object support callbacks
  210.  
  211. static    pascal OSErr StdCountProc        (DescType desiredClass,
  212.                                         DescType containerClass,
  213.                                         AEDesc *containerToken,
  214.                                         long *result);
  215.                                     
  216. static    pascal OSErr StdCompareProc    (DescType comparisonOperator,
  217.                                         AEDesc object,
  218.                                         DescType objOrDescToCompare,
  219.                                         Boolean& result);
  220.                                             
  221. static    pascal OSErr StdDisposeToken   (AEDesc *unneededToken);
  222.  
  223.  
  224.  
  225. #endif
  226.